package com.globallogic.token;

import java.util.Iterator;
import java.util.List;

import com.globallogic.draw.DrawContainer;
import com.globallogic.draw.Drawable;
import com.globallogic.inout.Out;

public class TokenHandlerGetSquare implements TokenHandler {
	
	@Override
	public void execute(TokenProcessor tokenProcessor, List<String> params) {
		
		Iterator<Drawable> iterator = DrawContainer.getInstance().iterator();
		Drawable drawObject;
		int cnt = 0;		
      	
    	while (iterator.hasNext()) {
    			
    		drawObject = iterator.next();
    		Out.printLn("square of " + drawObject + " is " + drawObject.calculateSquare());
    		cnt++;
    			
    	}
		    
    	if (cnt == 0) {
    		
    		Out.printLn("No object has been added!");
        	
        }
			
	}

}
